<template>
  <div>
    <el-dialog
    title="修改密码"
    :visible.sync="visible"
    width="30%"
  >
    <el-form :model="passwordForm">
      <el-form-item label="旧密码" :label-width="formLabelWidth">
        <el-input
          type="password"
          v-model="passwordForm.oldPassword"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="新密码" :label-width="formLabelWidth">
        <el-input
          type="password"
          v-model="passwordForm.newPassword"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="确认新密码" :label-width="formLabelWidth">
        <el-input
          type="password"
          v-model="passwordForm.confirmPassword"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">关闭</el-button>
      <el-button type="primary" @click="changePassword">确定</el-button>
    </div>
  </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    formLabelWidth: {
      type: String,
      default: '120px'
    }
  },
  data() {
    return {
      passwordForm: {
        oldPassword: '',
        newPassword: '',
        confirmPassword: ''
      }
    };
  },
  methods: {
    closeDialog() {
      this.$emit('update:visible', false);
    },
    changePassword() {
      if (this.passwordForm.newPassword !== this.passwordForm.confirmPassword) {
        this.$message.error('新密码和确认新密码不一致');
        return;
      }
    }
  }
     
  
};
</script>